<template>

    <div>
        <Row type="flex" justify="center" :gutter="16">

            <Col style="width:280px;">

            <Card dis-hover :bordered="false">

                <div>

                    <Row type="flex" justify="space-between" align="middle">

                        <Col span="14" style="padding-left:8px">

                        <h3 v-if="detail.isTerm">{{detail.Term}}</h3>

                        <h3 v-else>{{detail.gzYear}}年{{detail.IMonthCn}}{{detail.IDayCn}}</h3>

                        <p class="ivu-mb-8 sky-tips">{{detail.GlYear}}年{{detail.GlMonth}}月{{detail.GlDay}}日</p>

                        <p class="ivu-mb-8"><strong>{{detail.ncWeek}}</strong></p>

                        <p style="display:flex;justify-content: start;align-items: center;"
                           v-if="calendardata.reminder">

                            <Icon type="ios-chatboxes-outline" size="20"></Icon>

                            <Ellipsis :text="calendardata.reminder.content" :lines="1" tooltip ></Ellipsis>

                        </p>

                        </Col>

                        <Col>

                        <p class="quotations" v-if="calendardata.quotes">

                            {{calendardata.quotes.quotes}}</p>

                        </Col>

                    </Row>

                </div>

                <Divider class="ivu-mt-16 ivu-mb-16" ></Divider>

                <div>

                    <p class="fortune">今日运势</p>

                    <h1 class="ivu-mb-8" style="text-align: center;" v-if="calendardata.fortune">

                        {{calendardata.fortune.title}}</h1>

                    <Row type="flex" justify="space-between" align="middle" v-if="calendardata.fortune">

                        <Col style="width:150px">

                        <div class="ivu-mb-8" style="display:flex;justify-content: start;align-items: center;">

                            <font color="#19be6b">宜：</font>

                            <Ellipsis v-if="calendardata.fortune.suitable" :text="calendardata.fortune.suitable"
                                      :lines="1" tooltip ></Ellipsis>

                        </div>

                        <div style="display:flex;justify-content: start;align-items: center;">

                            <font color="#ed4014">忌：</font>

                            <Ellipsis v-if="calendardata.fortune.taboo" :text="calendardata.fortune.taboo" :lines="1"
                                      tooltip ></Ellipsis>

                        </div>

                        </Col>

                        <Col>

                        <p @click="clicksign(calendardata.sign.signin_status)" v-if="calendardata.sign.signin_status">

                            <img :src="require(`@/assets/expression/${calendardata.sign.signin_status}.gif`)" alt="">

                        </p>

                        <Button v-if="+this.calendardata.sign.have_sign === 0"
                                @click="clicksign(calendardata.sign.signin_status)" type="primary">签到</Button>

                        </Col>

                    </Row>

                </div>

            </Card>

            </Col>

            <Col style="width:calc(100% - 280px)">

            <Card dis-hover :bordered="false">

                <h3 class="ivu-mb-16">我的待办</h3>

                <Card :bordered="false" dis-hover
                      v-if="!dhflist.total&&!xslylist.total&&!(xskfbool&&xskflist.total)&&!publiclist.total">

                    <div style="height:53px;display:flex;justify-content: center;align-items: center;">暂无数据</div>

                </Card>

                <Row type="flex" :gutter="8" justify="start" align="top">

                    <Col span="6" v-if="dhflist.total&&+dhflist.total>=0">

                    <Card dis-hover :bordered="false" class="cardheight">

                        <h4>待回访 <Badge class="ivu-fr" :count="dhflist.total"></Badge>
                        </h4>

                        <template v-if="dhflist.list">

                            <dl class="sky-list" v-for="(item, index) in dhflist.list" :key="index">

                                <dt><a @click="handleOpen(1,item);">

                                    <strong v-if="item.user_name">{{item.user_name}} </strong>

                                    <span>{{item.gender_str}}</span>

                                    <span>{{item.age&&+item.age>0?item.age:''}}</span>

                                </a></dt>

                                <dd><a @click="ReturnVisit(item.id)">回访</a></dd>

                            </dl>

                        </template>

                        <Spin size="large" fix v-if="spindhf"></Spin>

                    </Card>

                    </Col>

                    <Col span="6" v-if="xslylist.total&&+xslylist.total>=0">

                    <Card :bordered="false" dis-hover class="cardheight">

                        <!-- <Row type="flex" justify="space-between" align="middle">

                        <Col>

                        <h4>线索-留言</h4>

                        </Col>

                        <Col>

                        <Badge :count="xslylist.total"></Badge>

                        </Col>

                    </Row>

                    <template v-if="xslylist.list">

                        <div v-for="(item, index) in xslylist.list" :key="index" class="ivu-mt-8">

                            <Row type="flex" justify="space-between" align="middle">

                                <Col style="display:flex">

                                <p class="username">{{item.user_name}}</p>

                                <p class="username ivu-pl-8 ivu-pr-8" style="width:46px;">{{item.gender_str}}</p>

                                <p class="username" style="width:18px">{{item.age&&+item.age>0?item.age:''}}</p>

                                </Col>

                                <Col><a @click="contactmessage(item.id)">联系</a></Col>

                            </Row>

                        </div>

                    </template> -->

                        <h4>线索-留言 <Badge class="ivu-fr" :count="xslylist.total"></Badge>
                        </h4>

                        <template v-if="xslylist.list">

                            <dl class="sky-list" v-for="(item, index) in xslylist.list" :key="index">

                                <dt><a @click="handleOpen(2,item);">

                                    <strong v-if="item.user_name">{{item.user_name}} </strong>

                                    <span>{{item.gender_str}}</span>

                                    <span>{{item.age&&+item.age>0?item.age:''}}</span>

                                </a></dt>

                                <dd><a @click="contactmessage(2,item)">联系</a></dd>

                            </dl>

                        </template>

                        <Spin size="large" fix v-if="spinxsly"></Spin>

                    </Card>

                    </Col>

                    <Col span="6" v-if="xskfbool&&xskflist.total&&+xskflist.total>=0">

                    <Card :bordered="false" dis-hover class="cardheight">

                        <!-- <Row type="flex" justify="space-between" align="middle">

                        <Col>

                        <h4>线索-客服</h4>

                        </Col>

                        <Col>

                        <Badge :count="xskflist.total"></Badge>

                        </Col>

                    </Row>

                    <template v-if="xskflist.list">

                        <div v-for="(item, index) in xskflist.list" :key="index" class="ivu-mt-8">

                            <Row type="flex" justify="space-between" align="middle">

                                <Col style="display:flex">

                                <p class="username">{{item.user_name}}</p>

                                <p class="username ivu-pl-8 ivu-pr-8" style="width:46px;">{{item.gender_str}}</p>

                                <p class="username" style="width:18px">{{item.age&&+item.age>0?item.age:''}}</p>

                                </Col>

                                <Col><a @click="contactservice(item.id)">联系</a></Col>

                            </Row>

                        </div>

                    </template> -->

                        <h4>线索-客服 <Badge class="ivu-fr" :count="xskflist.total"></Badge>
                        </h4>

                        <template v-if="xskflist.list">

                            <dl class="sky-list" v-for="(item, index) in xskflist.list" :key="index">

                                <dt style="width: calc(100% - 88px)"><a @click="handleOpen(3,item);">

                                    <strong v-if="item.user_name">{{item.user_name}} </strong>

                                    <span>{{item.gender_str}}</span>

                                    <span>{{item.age&&+item.age>0?item.age:''}}</span>

                                </a></dt>

                                <dd style="width: 30px"><a @click="contactmessage(3,item)">联系</a></dd>
                                <dd style="width: 58px"><a v-if="+item.repeat_user === 1" v-hasC="{
                                    name: '-v1-clue-user-repeat-user',
                                    flag: '/v1/clue/user/repeat-user',
                                }" @click="repeatuser(item)">患者重复</a></dd>

                            </dl>

                        </template>

                        <Spin size="large" fix v-if="spinxskf"></Spin>

                    </Card>

                    </Col>

                    <Col span="6" v-if="publiclist.total&&+publiclist.total>=0">

                    <Card :bordered="false" dis-hover class="cardheight">

                        <h4>即将进入公海 <Badge class="ivu-fr" :count="publiclist.total"></Badge>
                        </h4>

                        <template v-if="publiclist.list">

                            <dl class="sky-list" v-for="(item, index) in publiclist.list" :key="index">

                                <dt><a @click="handleOpen(4,item)">

                                    <strong v-if="item.user_name">{{item.user_name}} </strong>

                                    <span>{{item.gender_str}}</span>

                                    <span>{{item.age&&+item.age>0?item.age:''}}</span>

                                </a></dt>

                                <dd><a @click="ReturnVisits(item.id)">回访</a></dd>

                            </dl>

                        </template>

                        <Spin size="large" fix v-if="spinPublic"></Spin>

                    </Card>

                    </Col>

                </Row>

                <h3 class="sky-h3">信息完善</h3>

                <Card :bordered="false" dis-hover>

                    <Row type="flex" :gutter="16" align="middle">

                        <Col style="position: relative; width:280px">

                        <Row type="flex" justify="start" align="middle">

                            <Col class="boxflex">

                            <p class="ivu-text-center ivu-mb-8">

                            <h3>{{perfectlist.rate?perfectlist.rate.toFixed(2):'0.00'}}%</h3>

                            </p>

                            <p class="ivu-text-center">完善率</p>

                            </Col>

                            <Col class="ivu-ml-16" v-if="+perfectlist.compare_than!==0">

                            <p class="sky-i" v-if="+perfectlist.compare_than===-1">

                                <Icon type="md-arrow-down" color="#ed4014" ></Icon>低于平均值{{perfectlist.diff_rate.toFixed(2)}}%

                            </p>

                            <p class="sky-i" v-if="+perfectlist.compare_than===1">

                                <Icon type="md-arrow-up" color="#19be6b" ></Icon>高于平均值{{perfectlist.diff_rate.toFixed(2)}}%

                            </p>

                            </Col>

                        </Row>

                        <div class="biaoqian">

                            <div class="biaoqians">待完善</div>

                        </div>

                        </Col>

                        <Col style="width:calc(100% - 280px)">

                        <Row type="flex" justify="space-between" align="middle">

                            <Col class="boxflex">

                            <p class="ivu-text-center ivu-mb-8">

                            <h3><a
                                @click="clickdetail({name: '微信', num: perfectlist.sum_wechat, data_type:'sum_wechat'})"><strong>{{perfectlist.sum_wechat}}</strong></a>

                            </h3>

                            </p>

                            <p class="ivu-text-center">微信</p>

                            </Col>

                            <Col class="boxflex">

                            <p class="ivu-text-center ivu-mb-8">

                            <h3><a
                                @click="clickdetail({name: '手机号', num: perfectlist.sum_phone, data_type:'sum_phone'})"><strong>{{perfectlist.sum_phone}}</strong></a>

                            </h3>

                            </p>

                            <p class="ivu-text-center">手机号</p>

                            </Col>

                            <Col class="boxflex">

                            <p class="ivu-text-center ivu-mb-8">

                            <h3><a
                                @click="clickdetail({name: '性别', num: perfectlist.sum_gender, data_type:'sum_gender'})"><strong>{{perfectlist.sum_gender}}</strong></a>

                            </h3>

                            </p>

                            <p class="ivu-text-center">性别</p>

                            </Col>

                            <Col class="boxflex">

                            <p class="ivu-text-center ivu-mb-8">

                            <h3><a
                                @click="clickdetail({name: '年龄', num: perfectlist.sum_age, data_type:'sum_age'})"><strong>{{perfectlist.sum_age}}</strong></a>

                            </h3>

                            </p>

                            <p class="ivu-text-center">年龄</p>

                            </Col>

                            <Col class="boxflex">

                            <p class="ivu-text-center ivu-mb-8">

                            <h3><a
                                @click="clickdetail({name: '部位', num: perfectlist.sum_body_parts, data_type:'sum_body_parts'})"><strong>{{perfectlist.sum_body_parts}}</strong></a>

                            </h3>

                            </p>

                            <p class="ivu-text-center">部位</p>

                            </Col>

                        </Row>

                        </Col>

                    </Row>

                    <Spin size="large" fix v-if="spinperfect"></Spin>

                </Card>

                <Divider ></Divider>

                <Row :gutter="16" type="flex" align="middle" justify="space-between">

                    <Col>

                    <h3 class="ivu-mb-16">我的患者</h3>

                    </Col>

                    <Col>
                        <Row :gutter="16" type="flex" align="middle" justify="space-between">
                            <Col>
                                <searchTree 
                                class="ivu-mr-16"
                                    :multiple="true"
                                    :options="belongData"
                                    placeholder="归属人"
                                    :limit="3"
                                    :normalizer="normalizer"
                                    @input="valueChange"
                                    :limitText='limitText'
                                    noResultsText="无数据"
                                />
                            </Col>
                            <Col>
                                <DatePicker type="daterange" v-model="patienttime" @on-change="askDatapatient" placeholder="请选择日期"
                                style="width: 200px"></DatePicker>
                            </Col>
                        </Row>

                    </Col>

                </Row>

                <Card :bordered="false" dis-hover>

                    <Row type="flex" justify="space-between" align="middle">

                        <Col v-for="(item, index) in patientlist" :key="index" class="boxflex">

                        <div class="ivu-text-center">

                            <h3><a
                                @click="clickpatient({ data_type: '', name: item.status_name, num: item.num, patient_status_id: item.patient_status_id, time: patienttime})"><strong>{{item.num}}</strong></a>

                            </h3>

                        </div>

                        <p class="ivu-text-center ivu-mt-8">{{item.status_name}}</p>

                        </Col>

                    </Row>

                    <Spin size="large" fix v-if="spinPatient"></Spin>

                </Card>

                <Divider ></Divider>

                <Row :gutter="32" type="flex" align="middle" justify="space-between">

                    <Col>

                    <h3 class="ivu-mb-16">微信</h3>

                    </Col>

                    <Col>

                    <DatePicker type="daterange" v-model="wechattime" @on-change="askDatawechat" :clearable="false"
                                placeholder="请选择日期" style="width: 200px"></DatePicker>

                    </Col>

                </Row>
                <Card :bordered="false" dis-hover>

                    <template v-if="wxAllData.length>0">

                        <div v-for="(item,index) in wxAllData" :key="index">

                            <Row type="flex" justify="space-between" align="middle" class="ivu-mb-8">

                                <Col span="21">

                                <div class="sky-wxinr">

                                    <strong>昵称:{{item.wechatnick}}</strong>

                                    <span>{{item.wechatno}}</span>

                                    <span v-if="+item.isonline===0">
                                        <Badge status="success" text="在线" ></Badge>
                                    </span>

                                    <span v-if="+item.isonline===1">
                                        <Badge status="error" text="离线" ></Badge>
                                    </span>

                                    <span>
                                        <font color="#ed3f14">{{+item.isonline===0?'':'请检查手机软件是否开启，离线状态下数据无法同步'}}</font>
                                    </span>

                                </div>

                                </Col>

                                <Col span="3" class="ivu-text-right">

                                <Button size="small" type="primary" @click="handleReport(item)">查看报表</Button>

                                </Col>

                            </Row>

                            <Row type="flex" justify="space-between" class="sky-wxdata">

                                <Col>未读：<strong>{{item.count}}</strong></Col>

                                <Col>互动：<strong>{{item.message_total}}</strong></Col>

                                <Col>新增好友：<strong>{{item.new_friend}}</strong></Col>

                                <Col>标签率：<strong>{{(item.tag_ratio*100).toFixed(2)}}%</strong></Col>

                                <Col>备注率：<strong>{{(item.remark_ratio*100).toFixed(2)}}%</strong></Col>

                                <Col>拉黑/删除：<strong>{{item.backFriend}}</strong></Col>

                            </Row>

                            <Divider class="ivu-mt-8 ivu-mb-8"
                                     v-if="wechatlist.length>0&&+wechatlist.length>+index+1" ></Divider>

                        </div>

                    </template>

                    <template v-else>

                        <div style="height:53px;display:flex;justify-content: center;align-items: center;">暂无数据</div>

                    </template>

                    <Spin size="large" fix v-if="spinWechat"></Spin>

                </Card>

            </Card>

            </Col>

        </Row>

        <!-- <div class="fixedadd" @click="handleOpenDrawer">新增</div> -->

        <Button class="fixedadd" type="primary" shape="circle" @click="handleOpenDrawer">新增</Button>
        <div v-if="showCom">
            <robot-report :reportInfo="reportInfo" ref="robotReport" :wechattime="wechattime" ></robot-report>

            <edit-patient ref="editPatient" @patientfun="initial" ></edit-patient>

            <return-visit ref="returnVisit" @patientfuns="askDatadhf" ></return-visit>

            <return-visit ref="returnVisits" @patientfuns="askDatapublic" ></return-visit>

            <returnentry ref="returnentry" @askData="askDataxskf" ></returnentry>

            <returngrap ref="returngrap" @askData="askDataxsly" ></returngrap>

            <patientdetails ref="patient" @askData="askDatapatient" ></patientdetails>

            <patientdetail ref="detail" @askData="askDataperfect" ></patientdetail>

            
        </div>

        <patient-detail ref="patientDetail" :btnShow="btnShow" @cancelDrawer="askDataall" @askData="askDataall" ></patient-detail>

        <Modal v-model="imgmodal" title="请选择签到表情" @on-cancel="handleDrawerCancel">

            <div class="allimg">

                <Row type="flex" justify="space-between" class="code-row-bg">

                    <Col v-for="item in imglist1" :key="item">

                    <img @click="clickimg(item)" :class="{'active':+params.signin_status===+item}"
                         :src="require(`@/assets/expression/${item}.gif`)" alt="">

                    </Col>

                </Row>

                <Row type="flex" justify="space-between" class="code-row-bg">

                    <Col v-for="item in imglist2" :key="item">

                    <img @click="clickimg(item)" :class="{'active':+params.signin_status===+item}"
                         :src="require(`@/assets/expression/${item}.gif`)" alt="">

                    </Col>

                </Row>

                <Row type="flex" justify="space-between" class="code-row-bg">

                    <Col v-for="item in imglist3" :key="item">

                    <img @click="clickimg(item)" :class="{'active':+params.signin_status===+item}"
                         :src="require(`@/assets/expression/${item}.gif`)" alt="">

                    </Col>

                </Row>

            </div>

            <div slot="footer">

                <Button @click="handleDrawerCancel">取消</Button>

                <Button type="primary" @click="handleSubmit">确定</Button>

            </div>

        </Modal>
        <Modal title="患者重复数据" :mask-closable="false" footer-hide :width="80" v-model="repeatusers">
            <Table :max-height="400" :columns="repeatuserColumns" :data="repeatuserList" :loading="entryloadings">
                <template slot="user_name" slot-scope="{ row }">
                    <span class="ivu-mr-8">{{ row.user_name }}</span>
                    <span class="ivu-mr-8">{{ row.gender }}</span>
                    <span v-if="row.age">{{ row.age }}</span>
                </template>
                <template slot="realname" slot-scope="{ row }">
                    <span v-if="+row.patient_data_type === 0">{{ row.realname }}</span>
                </template>
                <template slot="status" slot-scope="{ row }">
                    <Tag v-if="+row.patient_status_id === 1" color="warning">{{
                        row.patient_status
                    }}</Tag>
                    <Tag v-else-if="+row.patient_status_id === 2" color="primary">{{
                        row.patient_status
                    }}</Tag>
                    <Tag v-else-if="+row.patient_status_id === 3" color="default">{{
                        row.patient_status
                    }}</Tag>
                    <Tag v-else-if="+row.patient_status_id === 4" color="success">{{
                        row.patient_status
                    }}</Tag>
                    <Tag v-else>{{ row.patient_status }}</Tag>
                </template>
            </Table>
        </Modal>

    </div>

</template>

<script>
    import {
        worktodowechatinfo,
        workpatientpatientlist,
        worktodocluegrab,
        worktodoclueentry,
        worktodocallback,
        worktodoentryseasoon,
        workpatientinformation,
        workcalendarcalendarlist,
        workpatientgetparamslist,
        workcalendarsignin
    } from '@api/hqapi/indextwo';
    import {
        clueuserrepeatuser
    } from '@api/hqapi';
    import returnVisit from '@/components/returnVisit';
    import robotReport from '@/components/robotReport';
    import editPatient from '@/components/editPatient';
    import returnentry from './returnentry';
    import returngrap from './returngrap';
    import patientdetail from './patientdetail';
    import patientdetails from './patientdetails';
    import patientDetail from '@/components/patientDetail';
    import calendar from '@/mixins/calendar';
    import { mapState, mapMutations } from 'vuex';
    import base64 from '../../../../libs/base64.js';
    import searchTree from '@riophae/vue-treeselect'
    export default {
        name: 'visit',
        components: {
            robotReport,
            editPatient,
            returnVisit,
            returnentry,
            returngrap,
            patientdetail,
            patientdetails,
            patientDetail,
            searchTree
        },
        data() {
            return {
                showCom:false,
                repeatusers: false,
                repeatuserList: [],
                entryloadings: false,
                repeatuserColumns: Object.freeze([
                    {
                        title: '基本信息',
                        slot: 'user_name'
                    },
                    {
                        title: '状态',
                        slot: 'status'
                    },
                    {
                        title: '归属人',
                        slot: 'realname'
                    },
                    {
                        title: '创建时间',
                        key: 'created_at'
                    }
                ]),
                imgmodal: false,
                imglist1: ['1', '2', '3', '4', '5'],
                imglist2: ['6', '7', '8', '9', '10'],
                imglist3: ['11', '12', '13', '14', '15'],
                reportInfo: {},
                detail: {},
                wechattime: [new Date(), new Date()],
                patienttime: [new Date(), new Date()],
                wechatlist: [],
                patientlist: [],
                belongData:[],
                belongValue:[],
                normalizer(node) {
                    return {
                        id: node.value,
                        label: node.label,
                        children: node.children,
                    }
                },
                limitText:function(count){
                    return `+ ${count}`
                }, 
                perfectlist: {},
                dhflist: [],
                xslylist: [],
                xskflist: [],
                publiclist: [],
                spinWechat: false,
                spinPatient: false,
                spinperfect: false,
                spindhf: false,
                spinxsly: false,
                spinxskf: false,
                spinPublic: false,
                xskfbool: false,
                calendardata: {},
                params: {
                    signin_status: '',
                    id: ''
                },
                askall: 0,
                login: true,
                btnShow: [
                    {
                        name: 'patient-index-sub5',
                        flag: 'v1/patient/index/sub'
                    },
                    {
                        name: 'patient-index-edit-remark5',
                        flag: 'v1/patient/index/edit-remark'
                    },
                    {
                        name: 'v1-patient-index-update',
                        flag: 'v1/patient/index/update'
                    },
                    {
                        name: 'patient-callback-callback-common-list4',
                        flag: 'v1/patient/callback/callback-common-list'
                    },
                    {
                        name: 'patient-index-edit-tags10',
                        flag: 'v1/patient/index/edit-tags'
                    },
                    {
                        name: 'patient-index-edit-tags13',
                        flag: 'v1/patient/index/edit-tags'
                    }
                ],

            };
        },
        computed: {
            ...mapState('power/export', [
                'wxAllData'
            ])
        },
        created() {
            // if (this.login) {
            //     let { username, password } = JSON.parse(localStorage.getItem("loginInfo"))
            //     let msg = {
            //         'Id': 1010,
            //         'AccessToken': '',
            //         'MsgType': 'DeviceAuthReq',
            //         'Content': {
            //             'AuthType': 2,
            //             'Credential': base64.b64EncodeUnicode(username + ':' + password)
            //         }
            //     }
            //     this.$websocket.sendSock(msg)
            //     this.login = false
            // }
        },
        /* 挂载完成能访问DOM元素 */
        mounted() {
            this.initial();
            
        },
        methods: {
            valueChange(e){
                this.belongValue=[]              
                e.forEach(item=>{  
                    let flag=true
                    this.belongData.forEach(ele=>{
                        if(ele.value==item){
                            flag=false
                            ele.children.forEach(id=>{
                                this.belongValue.push(id.value)
                            })
                        }
                    })  
                    if(flag){
                        this.belongValue.push(item)
                    }
                })
                this.askDatapatient()
            },
            getwork(){
                workpatientgetparamslist().then(res => {
                    this.paramslist = res;
                    this.askDataperfect();
                    this.askDatapatient();
                    // console.log(this.paramslist,'this.paramslist')
                });
            },
            repeatuser(data) {
                this.repeatusers = true;
                this.entryloadings = true;
                clueuserrepeatuser({
                    id: data.id
                }).then(res => {
                    this.repeatuserList = res;
                    this.entryloadings = false;
                });
            },
            ...mapMutations('power/export', [
                'changeWxAllData'
            ]),
            handleDrawerCancel() {
                this.imgmodal = false;
            },
            handleSubmit() {
                workcalendarsignin(this.params).then(res => {
                    this.params.id = res;
                    this.calendardata.sign.signin_status = this.params.signin_status;
                    this.calendardata.sign.have_sign = 1;
                    this.imgmodal = false;
                });
            },
            clicksign(num) {
                this.params.signin_status = num;
                this.imgmodal = true;
            },
            handleOpen(num, row) {
                this.askall = num;
                if(+num === 1 || +num === 4) {
                    this.$refs.patientDetail.handleOpen(row);
                }else if(+num === 3) {
                    // this.$refs.returnentry.handleContactClue(row);
                    this.$refs.returnentry.openInfo(row);
                }else if(+num === 2) {
                    // this.$refs.returngrap.openedit(row);
                    this.$refs.returngrap.openInfo(row);
                }
            },
            clickimg(num) {
                this.params.signin_status = num;
            },
            /* @函数功能: 初始化 */
            initial() {
                this.getwork();
                // console.log('111')
                let menus = JSON.parse(localStorage.getItem('menus'));
                for(let item of menus.sider) {
                    if(item.title === '线索') {
                        for(let items of item.children) {
                            if(items.title === '客服录入') {
                                this.xskfbool = true;
                            }
                        }
                    }
                }
                let date = this.$Date().format('YYYY-MM-DD').split('-');
                this.setDetail({ year: date[0], month: date[1], day: date[2] });
                this.askDatadhf();
                this.askDataxsly();
                this.askDataxskf();
                this.askDatapublic();
                this.askDatawechat();
                this.askDatacalendar();
            },
            askDataall() {
                if(this.askall === 1) {
                    this.askDatadhf();
                }else if(this.askall === 2) {
                    this.askDataxsly();
                }else if(this.askall === 3) {
                    this.askDataxskf();
                }else if(this.askall === 4) {
                    this.askDatapublic();
                }
            },
            askDatacalendar() {
                workcalendarcalendarlist().then(res => {
                    this.calendardata = res;
                    this.params.id = this.calendardata.sign.id ? this.calendardata.sign.id : '';
                    this.params.signin_status = this.calendardata.sign.signin_status ? this.calendardata.sign.signin_status : '';
                });
            },
            askDatadhf() {
                this.spindhf = true;
                worktodocallback().then(res => {
                    this.dhflist = res;
                    this.spindhf = false;
                });
            },
            askDataxsly() {
                this.spinxsly = true;
                worktodocluegrab().then(res => {
                    this.xslylist = res;
                    this.spinxsly = false;
                });
            },
            askDataxskf() {
                this.spinxskf = true;
                worktodoclueentry().then(res => {
                    this.xskflist = res;
                    this.spinxskf = false;
                });
            },
            askDatapublic() {
                this.spinPublic = true;
                worktodoentryseasoon().then(res => {
                    this.publiclist = res;
                    this.spinPublic = false;
                });
            },
            askDatapatient() {
                this.spinPatient = true;
                let patienttimes = { 
                    start_time: this.patienttime[0], 
                    end_time: this.patienttime[1],
                    belong_member_id: this.belongValue.join(",")
                };
                workpatientpatientlist(patienttimes).then(res => {
                    this.patientlist = res.list;
                    this.belongData=res.condition.member_list
                    this.spinPatient = false;
                });
            },

            askDatawechat() {
                this.spinWechat = true;
                let paramswechat = { start: this.wechattime[0], end: this.wechattime[1] };
                worktodowechatinfo(paramswechat).then(res => {
                    this.wechatlist = res;
                    this.changeWxAllData(res.map(ee => {
                        return {
                            ...ee,
                            count: 0
                        };
                    }));
                    this.spinWechat = false;
                }).catch(error => {
                    this.spinWechat = false;
                })
            },
            askDataperfect() {
                this.spinperfect = true;
                workpatientinformation().then(res => {
                    this.perfectlist = res;
                    this.spinperfect = false;
                });
            },
            setDetail(date) {
                this.detail = calendar.solar2lunar(date.year, date.month, date.day);
            },
            handleReport(row) {
                this.reportInfo = row;
                this.showCom=true
                this.$nextTick(()=>{
                    this.$refs.robotReport.handleRobot(this.wechattime, row);
                })
            },
            handleOpenDrawer() {
                this.showCom=true
                this.$nextTick(()=>{
                    this.$refs.editPatient.handleOpenDrawer();
                })
               
            },
            ReturnVisit(id) {
                this.showCom=true
                this.$nextTick(()=>{
                    this.$refs.returnVisit.handleReturnVisit(id);
                })
            },
            ReturnVisits(id) {
                this.showCom=true
                this.$nextTick(()=>{
                    this.$refs.returnVisits.handleReturnVisit(id);
                })
            },
            contactmessage(num, row) {
                this.showCom=true
                this.$nextTick(()=>{
                    if(+num === 3) {
                        this.$refs.returnentry.handleContactClue(row);
                    }else if(+num === 2) {
                        this.$refs.returngrap.openedit(row);
                    }
                })
               
            },
            clickdetail(data) {
                this.showCom=true
                this.$nextTick(()=>{
                    this.$refs.detail.detail(data,this.paramslist);
                })
                
            },
            clickpatient(data) {
                this.showCom=true
                if(data.name === '全部患者') {
                    data.patient_status_id = '';
                }else if(data.name === '新患者') {
                    data.patient_status_id = '';
                    data.data_type = 'new_patient';
                }
                data.belong_member_id=this.belongValue.join(',')
                this.$nextTick(()=>{
                    this.$refs.patient.patient(data, this.paramslist);
                })
                
            }
        },
    };
</script>
<style scoped>
    /deep/.ivu-tooltip-rel {
        display: inline-block;
    }

    .fixedadd {
        position: fixed;
        display: flex;
        align-items: center;
        justify-content: center;
        bottom: 50px;
        right: 50px;
        height: 55px;
        width: 55px;
        color: #fff;
        box-shadow: 3px 3px 15px #999;
        border-radius: 50%;
    }

    .biaoqian {
        position: absolute;
        top: -16px;
        right: 30px;
        width: 10px;
        height: 65px;
        border: 10px solid;
        border-color: #297ed9 #297ed9 rgba(255, 255, 255, 0) #297ed9;
    }

    .biaoqians {
        position: absolute;
        top: -8px;
        left: -10px;
        font-size: 10px;
        color: #f2f2f2;
        width: 20px;
        text-align: center;
    }

    .sky-list dt {
        width: 80%;
        height: 32px;
        line-height: 32px;
        float: left;
        font-size: 13px;
    }

    .sky-list dt strong {
        font-weight: bold;
        margin-right: 4px;
    }

    .sky-list dt span {
        margin-right: 4px;
        color: #888;
    }

    .sky-list dd {
        width: 20%;
        height: 32px;
        line-height: 32px;
        text-align: right;
        float: left;
    }

    .username {
        height: 26px;
        line-height: 26px;
        vertical-align: middle;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: 70px;
        color: #777;
        border-bottom: 1px solid #999
    }

    .cardheight {
        height: 145px;
        overflow: hidden;
        background: #f2f2f2
    }

    .cardheight h4 {
        color: #666;
        margin-bottom: 8px;
    }

    .allimg img {
        padding: 2px;
        border: 2px solid rgba(0, 0, 0, 0);
    }

    .active {
        border: 2px solid #297ed9 !important;
    }

    .boxflex {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .boxflex strong {
        font-size: 18px;
    }

    .quotations {
        writing-mode: tb-rl;
        font-size: 13px;
        height: 150px;
        text-align: center;
        color: #888;
        padding: 8px;
        writing-mode: tb-rl;
        font-size: 13px;
        height: 150px;
        text-align: center;
        /* font-family: 'KaiTi'; */
        color: #888;
        color: #000;
        padding: 8px;

    }

    .sky-tips {
        font-size: 12px;
        color: #999;
    }

    .fortune {
        font-size: 14px;
        color: #888;
        margin-bottom: 4px;
        text-align: center
    }

    .sky-h3 {
        font-size: 16px;
        margin: 24px 0 16px 0;
        color: #333;
    }

    .sky-i {
        color: #888;
        font-size: 10px;
    }

    .sky-wxinr {
        height: 32px;
        line-height: 32px;
    }

    .sky-wxinr strong {
        font-size: 14px;
    }

    .sky-wxinr span {
        margin-left: 8px;
        color: #888;
    }

    .sky-wxdata {
        color: #888;
        font-size: 13px;
    }

    .sky-wxdata strong {
        font-weight: bold;
        font-size: 16px;
        color: #333;
    }

    .repeatColor {
        color: red;
    }
</style>
